package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.biz.domain.BizStockyardTrainPosition;
import com.ruoyi.biz.service.IBizStockyardTrainPositionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 整备场火车位置信息Controller
 * 
 * @author cc
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/system/stockyard_train_position")
public class BizStockyardTrainPositionController extends BaseController
{
    @Autowired
    private IBizStockyardTrainPositionService bizStockyardTrainPositionService;

    /**
     * 查询整备场火车位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizStockyardTrainPosition bizStockyardTrainPosition)
    {
        startPage();
        List<BizStockyardTrainPosition> list = bizStockyardTrainPositionService.selectBizStockyardTrainPositionList(bizStockyardTrainPosition);
        return getDataTable(list);
    }

    /**
     * 导出整备场火车位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:export')")
    @Log(title = "整备场火车位置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizStockyardTrainPosition bizStockyardTrainPosition)
    {
        List<BizStockyardTrainPosition> list = bizStockyardTrainPositionService.selectBizStockyardTrainPositionList(bizStockyardTrainPosition);
        ExcelUtil<BizStockyardTrainPosition> util = new ExcelUtil<BizStockyardTrainPosition>(BizStockyardTrainPosition.class);
        util.exportExcel(response, list, "整备场火车位置信息数据");
    }

    /**
     * 获取整备场火车位置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizStockyardTrainPositionService.selectBizStockyardTrainPositionById(id));
    }

    /**
     * 新增整备场火车位置信息
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:add')")
    @Log(title = "整备场火车位置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizStockyardTrainPosition bizStockyardTrainPosition)
    {
        return toAjax(bizStockyardTrainPositionService.insertBizStockyardTrainPosition(bizStockyardTrainPosition));
    }

    /**
     * 修改整备场火车位置信息
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:edit')")
    @Log(title = "整备场火车位置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizStockyardTrainPosition bizStockyardTrainPosition)
    {
        return toAjax(bizStockyardTrainPositionService.updateBizStockyardTrainPosition(bizStockyardTrainPosition));
    }

    /**
     * 删除整备场火车位置信息
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:remove')")
    @Log(title = "整备场火车位置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizStockyardTrainPositionService.deleteBizStockyardTrainPositionByIds(ids));
    }

    /**
     * 获取整备场火车位置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:query')")
    @GetMapping(value = "/getAllByDrawing/{drawingId}")
    public AjaxResult getAllByDrawing(@PathVariable("drawingId") Long drawingId)
    {
        return success(bizStockyardTrainPositionService.getAllByDrawing(drawingId));
    }

    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:add')")
    @Log(title = "放置火车", businessType = BusinessType.INSERT)
    @PostMapping("/enterTrain")
    public AjaxResult enterTrain(@RequestBody BizStockyardTrainPosition bizStockyardTrainPosition){
        return success(bizStockyardTrainPositionService.enterTrain(bizStockyardTrainPosition,getLoginUser()));
    }

    @PreAuthorize("@ss.hasPermi('system:stockyard_train_position:remove')")
    @Log(title = "离开火车", businessType = BusinessType.DELETE)
    @PostMapping("/exitTrain")
    public AjaxResult exitTrain(@RequestBody BizStockyardTrainPosition bizStockyardTrainPosition){
        return success(bizStockyardTrainPositionService.exitTrain(bizStockyardTrainPosition,getLoginUser()));
    }
}
